class RefreshTrigger {
  constructor(refreshFun) {
    this.refreshFun = refreshFun;
    this.inited = false;
    this.callToOther = false;
  }

  refresh() {
    if (!this.inited) {
      this.refreshFun();
      this.inited = true;
    } else if (this.callToOther) {
      this.refreshFun();
      this.callToOther = false;
    }
  }

  navigateTo(options) {
    wx.navigateTo(options);
    this.callToOther = true;
  }
}

module.exports = RefreshTrigger;
